package com.woniuxy.exam.utils;

import com.woniuxy.commons.entity.Paper;
import com.woniuxy.commons.entity.PaperStructure;
import com.woniuxy.exam.entity.PaperDto;

/**
 * @Author 余枭春
 * @Date 2020/7/20 9:56
 * @Description:
 **/
public class PaperUtil {
    /**
     * 判断是否为自动组卷
     *
     * @param paperStructure
     * @return 所有题型数目都不为零就返回true，只要有一种题型设定数目不为零，就返回false
     */
    public static boolean shouldDoAuto(PaperStructure paperStructure) {
        if (paperStructure.getAnswerNum() == 0 && paperStructure.getCompletionNum() == 0 && paperStructure.getMultipleChoiceNum() == 0 && paperStructure.getSingleChoiceNum() == 0 && paperStructure.getTrueOrFalseNum() == 0) {
            return true;
        }
        return false;
    }

    /**
     * 将试卷封装到 试卷业务类中
     *
     * @param paper
     * @return
     */
    public static void paperToPaperDto(Paper paper,PaperDto paperDto) {
        paperDto.setId(paper.getId());
        paperDto.setName(paper.getName());
        paperDto.setTestType(paper.getTestType());
        paperDto.setPaperType(paper.getPaperType());
        paperDto.setBorderline(paper.getBorderline());
        paperDto.setTime(paper.getTime());
        paperDto.setClassificationId(paper.getClassificationId());
        paperDto.setStatus(paper.getStatus());
    }
}
